package org.example.springyuanli.demos.test;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class Controller {


    @Autowired
    private ApplicationContext applicationContext;

    @Autowired
    private Dog singleDog;

    @Autowired
    private Dog prototypeDog;

    @RequestMapping("/prototype")
    public String prototype() {
        return "prototype: " + prototypeDog.toString() + "  context:" + applicationContext.getBean("prototypeDog");
    }

    @Autowired
    private Dog requestDog;

    @RequestMapping("request")
    public String re() {
        return "request: " + requestDog.toString() + "  context:" + applicationContext.getBean("requestDog");
    }

    @Autowired
    private Dog sessionDog;

    @RequestMapping("session")
    public String se() {
        return "sessionDog: " + sessionDog.toString() + "  context:" + applicationContext.getBean("sessionDog");
    }

    @Autowired
    protected Dog applicationDog;

    public String app() {
        return "applicationDog: " + applicationDog.toString() + "  context:" + applicationContext.getBean("applicationDog");
    }
}
